﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Bussiness;

namespace WebApplication.Admin
{
    public partial class BaoCaoNhapTheoThang : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadMathang();
            }
        }

        protected void lbtnxem_Click(object sender, EventArgs e)
        {
            int thang=int.Parse(Dlthang.SelectedValue);
            int nam=int.Parse(Dlnam.SelectedValue);
            string mamh=Dlmathang.SelectedValue;
            string ngay="Tháng :"+thang.ToString()+ "," +"Năm:"+nam.ToString();
            var source = new Microsoft.Reporting.WebForms.ReportDataSource("BaoCaoNhapTheoThang", new Baocao.BaoCaoNhapTheoThang().GetBaoCaoNhapTheoThang(thang, nam, ngay, mamh));
            ReportViewer1.LocalReport.ReportPath=@"Admin\Baocao\BaoCaoNhapTheoThang.rdlc";
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(source);
            ReportViewer1.LocalReport.Refresh();
        }
        public void LoadMathang()
        {
            IUnitOfWork iunitfwork = new EFUnitOfWork();
            MATHANGRepository repository = new MATHANGRepository(new EFRepository<MATHANG>(), iunitfwork);
            IQueryable<MATHANG> objmathang = repository.All();
            Dlmathang.DataSource = objmathang;
            Dlmathang.DataValueField = "MAMH";
            Dlmathang.DataTextField = "TENMH";
            Dlmathang.DataBind();
            Dlmathang.Items.Insert(0, new ListItem { Text="---Chọn mặt hàng---",Value="0" });
            Dlthang.Items.Insert(0, new ListItem { Text = "---Chọn tháng hàng---", Value = "0" });
            Dlnam.Items.Insert(0, new ListItem { Text = "---Chọn năm hàng---", Value = "0" });
        }
    }
}